package logic

import (
	"context"
	"product/model/mysql"

	"product/userrpc/internal/svc"
	"product/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type LoginLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoginLogic {
	return &LoginLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *LoginLogic) Login(in *userrpc.LoginRequest) (*userrpc.LoginResponse, error) {
	user := mysql.User{
		Tel:      in.Tel,
		Password: in.Password,
	}
	mysql.DB.Debug().Find(&user)
	return &userrpc.LoginResponse{Id: int64(user.ID)}, nil
}
